﻿#region Copyright 
/*-------------------------------------------------------------------------
* 命名空间名称/文件名:    SSPivot.Common.ViewModel/BaseApiResponse 
* CLR版本:     4.0.30319.42000
* 机器名称:    DESKTOP-NHMLO8A
* 功 能：       N/A
* 类 名：       BaseApiResponse
* 创建时间：  2025/5/22 18:40:23
* 版本号：      v1.0
* 创建人:        xulong
*-------------------------------------------------------------------------*/
#endregion 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Common.ViewModel
{
    #region 接口响应

    /// <summary>
    /// 基础响应（无Result）
    /// </summary>
    public class BaseApiResponse : ServiceResultBase
    {
        /// <summary>
        /// 创建响应结果
        /// </summary>
        /// <returns></returns>
        public static BaseApiResponse Create()
        {
            return new BaseApiResponse();
        }
    }
    /// <summary>
    /// 对象响应结果
    /// </summary>
    /// <typeparam name="TResult"></typeparam>
    public class BaseApiResponse<TResult> : ServiceResultBase
    {
        /// <summary>
        /// 响应结果
        /// </summary>
        public TResult Result { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public BaseApiResponse() { }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="result"></param>
        public BaseApiResponse(TResult result)
        {
            this.Result = result;
        }

        /// <summary>
        /// 创建响应结果
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public static BaseApiResponse<TResult> Create(TResult result)
        {
            return new BaseApiResponse<TResult>(result);
        }
    }
    /// <summary>
    /// 列表响应结果
    /// </summary>
    /// <typeparam name="TListType"></typeparam>
    public class BaseApiListResponse<TListType> : BaseApiResponse<IList<TListType>>
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public BaseApiListResponse() { }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="result"></param>
        public BaseApiListResponse(IList<TListType> result)
        {
            this.Result = result;
        }

        /// <summary>
        /// 创建响应结果
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public static new BaseApiListResponse<TListType> Create(IList<TListType> result)
        {
            return new BaseApiListResponse<TListType>(result);
        }
    }
    /// <summary>
    /// 带分页列表响应结果
    /// </summary>
    /// <typeparam name="TListType"></typeparam>
    public class BaseApiPageResponse<TListType> : BaseApiListResponse<TListType>
    {
        /// <summary>
        /// 分页信息
        /// </summary>
        public PageResult Page { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public BaseApiPageResponse() { }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="result"></param>
        /// <param name="page"></param>
        public BaseApiPageResponse(IList<TListType> result, PageResult page)
        {
            this.Result = result;
            this.Page = page;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="result"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        public BaseApiPageResponse(IList<TListType> result, int pageNo, int pageSize)
        {
            this.Result = result;
            this.Page = new PageResult() { PageNo = pageNo, PageSize = pageSize };
        }

        /// <summary>
        /// 创建响应结果
        /// </summary>
        /// <param name="result"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public static BaseApiPageResponse<TListType> Create(IList<TListType> result, PageResult page)
        {
            return new BaseApiPageResponse<TListType>(result, page);
        }

        /// <summary>
        /// 创建响应结果
        /// </summary>
        /// <param name="result"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public static BaseApiPageResponse<TListType> Create(IList<TListType> result, int pageNo, int pageSize)
        {
            return new BaseApiPageResponse<TListType>(result, pageNo, pageSize);
        }
    }

    /// <summary>
    /// 带分页对象（不仅仅返回一个List集合，是一个数据对象包含List）
    /// </summary>
    /// <typeparam name="TResult"></typeparam>
    public class PageApiResponse<TResult> : BaseApiResponse<TResult>
    {
        /// <summary>
        /// 分页信息
        /// </summary>
        public PageResult Page { get; set; }
    }
    #endregion
}
